//
//  ZDBHomeTableViewCell.m
//  ZDB
//
//  Created by Kk on 2020/3/14.
//  Copyright © 2020 ZDB. All rights reserved.
//

#import "ZDBHomeTableViewCell.h"

@implementation ZDBHomeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    KViewRadius(_bgView, 4);
    self.backgroundColor = VIEWBGCOLOR;
    self.selectionStyle = UITableViewCellAccessoryNone;
    self.statusBtn.selected = YES;
   
    _bgView.backgroundColor = WHITECOLOR;
    _bgView.layer.shadowColor = [UIColor colorWithRed:6/255.0 green:0/255.0 blue:1/255.0 alpha:0.25].CGColor;
    _bgView.layer.shadowOffset = CGSizeMake(0,0);
    _bgView.layer.shadowOpacity = 1;
    _bgView.layer.shadowRadius = 5;
    _bgView.layer.cornerRadius = 2;
}
#pragma 任务1
- (void)setOneTaskModel:(TaskInfoListModel *)oneTaskModel
{
//    [_icon sd_setImageWithURL:[NSURL URLWithString:oneTaskModel.taskUrl]];
     [_icon sd_setImageWithURL:[NSURL URLWithString:oneTaskModel.taskUrl] placeholderImage:[UIImage imageNamed:@"renwunoon"]];
    _taskTitle.text = oneTaskModel.taskTitle;
    NSString *joinNumber = kStringIsEmpty(oneTaskModel.joinNumber)?@"0":oneTaskModel.joinNumber;
    NSString *taskNumber = kStringIsEmpty(oneTaskModel.taskNumber)?@"0":oneTaskModel.taskNumber;
    _testInfo.text = kFormat(@"参与人数：%@ | 剩余次数：%@次", joinNumber,taskNumber);
    _vipImg.image = [UIImage imageNamed:@"vip1"];
    NSString * str = kFormat(@"%@  %@发布", @"青铜会员及以上可领取", [ZBDUnit getOtherTimeStrWithString:oneTaskModel.createTime]);
    self.vipLab.attributedText = [ZBDUnit finderattributedString:str attributedString:@"青铜会员及以上可领取" color:ColorStr(@"#eb75b6") font:AutoFont(10)];
    _price.text = kFormat(@"¥ %@", oneTaskModel.taskMoney);
    switch (oneTaskModel.isReceive.integerValue) {//1=可领取 2=不可以 3=可提交 4=进行中 5=审核中  6=已完成 7=完成失败
        case 1:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"可领取" forState:UIControlStateSelected];
            break;
        case 2:
            _statusBtn.selected = NO;
             [_statusBtn setTitle:@"已领取" forState:UIControlStateNormal];
            break;
        case 3:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"待提交" forState:UIControlStateSelected];
            break;
        case 4:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"进行中" forState:UIControlStateSelected];
            break;
        case 5:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"审核中" forState:UIControlStateSelected];
            break;
        case 6:
            _statusBtn.selected = NO;
            [_statusBtn setTitle:@"已完成" forState:UIControlStateNormal];
            
            break;
        case 7:
            _statusBtn.selected = NO;
             [_statusBtn setTitle:@"任务失败" forState:UIControlStateNormal];
            
            break;
        default:
            break;
    }
   
}
#pragma 任务2
- (void)setTwoTaskModel:(TaskRegistersModel *)twoTaskModel
{
    _vipImg.image = [UIImage imageNamed:@"vip2"];
//    [_icon sd_setImageWithURL:[NSURL URLWithString:twoTaskModel.taskUrl]];
    [_icon sd_setImageWithURL:[NSURL URLWithString:twoTaskModel.taskUrl] placeholderImage:[UIImage imageNamed:@"renwunoon"]];
    _taskTitle.text = twoTaskModel.title;
    NSString *askNumber = kStringIsEmpty(twoTaskModel.askNumber)?@"0":twoTaskModel.askNumber;
    NSString *completeNumber = kStringIsEmpty(twoTaskModel.completeNumber)?@"0":twoTaskModel.completeNumber;
    _testInfo.text = kFormat(@"要求人数：%@ | 完成人数：%@", askNumber,completeNumber);
    NSString * str = kFormat(@"%@  %@发布", @"白银会员及以上可领取", [ZBDUnit getOtherTimeStrWithString:twoTaskModel.createTime]);
    self.vipLab.attributedText = [ZBDUnit finderattributedString:str attributedString:@"白银会员及以上可领取" color:ColorStr(@"#023089") font:AutoFont(10)];
    _price.text = kFormat(@"¥ %@", twoTaskModel.money);
    switch (twoTaskModel.isReceive.integerValue) {//1=可领取 2=进行中 3=可提交 4=审核中
        case 1:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"可领取" forState:UIControlStateSelected];
            break;
        case 2:
            _statusBtn.selected = NO;
            [_statusBtn setTitle:@"进行中" forState:UIControlStateNormal];
            break;
        case 3:
            _statusBtn.selected = YES;
            [_statusBtn setTitle:@"可提交" forState:UIControlStateSelected];
            break;
        case 4:
            _statusBtn.selected = NO;
            [_statusBtn setTitle:@"审核中" forState:UIControlStateNormal];
            break;
        default:
            break;
    }
}
#pragma 任务3
- (void)setThreeTaskModel:(TaskRechargesModel *)threeTaskModel
{
    _vipImg.image = [UIImage imageNamed:@"vip3"];
//    [_icon sd_setImageWithURL: [NSURL URLWithString:threeTaskModel.taskUrl]];
    [_icon sd_setImageWithURL:[NSURL URLWithString:threeTaskModel.taskUrl] placeholderImage:[UIImage imageNamed:@"renwunoon"]];
       _taskTitle.text = threeTaskModel.title;
       NSString *rechargeRatio = kStringIsEmpty(threeTaskModel.rechargeRatio)?@"0":threeTaskModel.rechargeRatio;
       _testInfo.text = kFormat(@"平台充值佣金比例：%@%@", rechargeRatio,@"%");
       NSString * str = kFormat(@"%@  %@发布", @"黄金会员及以上可领取", [ZBDUnit getOtherTimeStrWithString:threeTaskModel.createTime]);
       self.vipLab.attributedText = [ZBDUnit finderattributedString:str attributedString:@"黄金会员及以上可领取" color:ColorStr(@"#fdad00") font:AutoFont(10)];
       _price.text = @"";
       switch (threeTaskModel.isReceive.integerValue) {//任务状态 1=可领取 2=进行中
           case 1:
               _statusBtn.selected = YES;
               [_statusBtn setTitle:@"可领取" forState:UIControlStateSelected];
               break;
           case 2:
               _statusBtn.selected = NO;
               [_statusBtn setTitle:@"进行中" forState:UIControlStateNormal];
               break;
           default:
               break;
       }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
